@page
@model PreCreateModel
@{
    ViewData["Title"] = "统一收单线下交易预创建";
}
<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
            <a asp-page="/Index">首页</a>
        </li>
        <li class="breadcrumb-item">
            <a asp-page="/Alipay/Index">支付宝</a>
        </li>
        <li class="breadcrumb-item">
            <a asp-page="/Alipay/Payments/Index">支付产品</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">@ViewData["Title"]</li>
    </ol>
</nav>
<div class="card mb-3">
    <div class="card-header">
        @ViewData["Title"]
    </div>
    <div class="card-body">
        <form method="post">
            <div class="mb-3">
                <label class="form-label" asp-for="Input.OutTradeNo"></label>
                <input class="form-control" asp-for="Input.OutTradeNo"/>
            </div>
            <div class="mb-3">
                <label class="form-label" asp-for="Input.TotalAmount"></label>
                <input class="form-control" asp-for="Input.TotalAmount"/>
            </div>
            <div class="mb-3">
                <label class="form-label" asp-for="Input.Subject"></label>
                <input class="form-control" asp-for="Input.Subject"/>
            </div>
            <div class="mb-3">
                <label class="form-label" asp-for="Input.NotifyUrl"></label>
                <input class="form-control" asp-for="Input.NotifyUrl"/>
            </div>
            <button class="btn btn-primary mb-3" type="submit">提交请求</button>
        </form>
        <hr/>
        @if (ViewData["qr_code"] is string data && !string.IsNullOrEmpty(data))
        {
            using var qrGenerator = new QRCodeGenerator();
            using var qrCodeData = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
            using var base64ByteQrCode = new Base64QRCode(qrCodeData);
            var base64Str = base64ByteQrCode.GetGraphic(20, Color.Black, Color.White, false, Base64QRCode.ImageType.Png);
            <div class="mb-3">
                <label class="form-label">二维码</label>
                <embed src="data:image/png;base64,@base64Str" class="bg-light shadow-sm rounded d-block p-3 mb-5" type="image/png" width="180" height="180" />
            </div>
        }
        @if (ViewData["response"] is string response && !string.IsNullOrEmpty(response))
        {
            <div class="mb-3">
                <label class="form-label">应答</label>
                <textarea class="form-control" rows="10">@response</textarea>
            </div>
        }
    </div>
</div>

@section scripts {
    @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
